/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package deatax;

import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.LinkedList;
import java.util.Map.Entry;

/**
 *
 * @author pson
 */
public class Landmass {

    private String name;
    private LinkedHashMap<Terrain, Integer> ratio;
    private LinkedList<Terrain> bag = null;

    public Landmass(String name) {
        this.name = name;
        ratio = new LinkedHashMap<Terrain, Integer>();
    }

    public void addCondition(Terrain t, Integer chance) {
        ratio.put(t, chance);
    }

    public Terrain generateTerrain() {
        if (bag == null || bag.isEmpty()) {
            bag = new LinkedList<Terrain>();
            for (Entry<Terrain, Integer> e : ratio.entrySet()) {
                for (int i = 0; i < e.getValue(); ++i) {
                    bag.add(e.getKey());
                }
            }
        }
        return bag.remove(RNG.rand(bag.size()));
    }
}
